const customElements = ['bpmn:Task','bpmn:EndEvent'] // 自定义元素的类型,需要拖拽后显示自定义的元素
const customElements2 = ['bpmn:Task', 'bpmn:StartEvent', 'bpmn:EndEvent', 'bpmn:Task', 'bpmn:BusinessRuleTask', 'bpmn:ExclusiveGateway', 'bpmn:DataObjectReference'] // 自定义元素的类型,需要拖拽后显示自定义的元素

const STATICPATH = 'https://hexo-blog-1256114407.cos.ap-shenzhen-fsi.myqcloud.com/' // 静态文件路径

const customConfig = { // 自定义元素的配置
    'bpmn:StartEvent': {
        'field': 'start',
        'title': '开始节点',
        'attr': { x: 0, y: 0, width: 40, height: 40 },
    },
    'bpmn:EndEvent': {
        'field': 'end',
        'title': '结束节点',
        'attr': { x: 0, y: 0, width: 40, height: 40 },
        'url':'https://hexo-blog-1256114407.cos.ap-shenzhen-fsi.myqcloud.com/end.png'
    },
    'bpmn:SequenceFlow': {
        'field': 'flow',
        'title': '连接线',
    },
    'bpmn:Task': {
        'field': 'rules',
        'title': '普通任务',
        'attr': { x: 0, y: 0, width: 48, height: 48 },
        'url': 'https://hexo-blog-1256114407.cos.ap-shenzhen-fsi.myqcloud.com/rules.png'
    },
    'bpmn:BusinessRuleTask': {
        'field': 'variable',
        'title': 'businessRule任务',
        'attr': { x: 0, y: 0, width: 48, height: 48 }
    },
    'bpmn:ExclusiveGateway': {
        'field': 'decision',
        'title': '网关',
        'attr': { x: 0, y: 0, width: 48, height: 48 }
    },
    'bpmn:DataObjectReference': {
        'field': 'score',
        'title': '变量',
        'attr': { x: 0, y: 0, width: 48, height: 48 }
    }
}

const hasLabelElements = ['bpmn:StartEvent', 'bpmn:EndEvent', 'bpmn:ExclusiveGateway', 'bpmn:DataObjectReference'] // 一开始就有label标签的元素类型


const customFlowAction = [// 线
    // {
    //     type: 'hand-tool',
    //     action: ['bpmn-icon-hand-tool', 'tools', 'bpmn-icon-hand-tool', 'Activate the hand tool']
    // },
    {
        type: 'global-connect-tool',
        action: ['bpmn:SequenceFlow', 'tools', 'icon-custom icon-custom-flow', '连接线']
    }]

const customShapeAction = [ // shape
    {
        type: 'create.start-event',
        action: ['bpmn:StartEvent', 'event', 'icon-custom icon-custom-start', '开始节点']
    },
    {
        type: 'create.end-event',
        action: ['bpmn:EndEvent', 'event', 'icon-custom icon-custom-end', '结束节点']
    },
    {
        type: 'create.task',
        action: ['bpmn:Task', 'activity', 'icon-custom icon-custom-task', '普通任务']
    },
    {
        type: 'create.businessRule-task',
        action: ['bpmn:BusinessRuleTask', 'activity', 'icon-custom icon-custom-businessRule', 'businessRule任务']
    },
    {
        type: 'create.exclusive-gateway',
        action: ['bpmn:ExclusiveGateway', 'activity', 'icon-custom icon-custom-exclusive-gateway', '网关']
    },
    {
        type: 'create.dataObjectReference',
        action: ['bpmn:DataObjectReference', 'activity', 'icon-custom icon-custom-data', '变量']
    }
]



/**
* 循环创建出一系列的元素
* @param {Array} actions 元素集合
* @param {Object} fn 处理的函数
*/
export function batchCreateCustom(actions, fn) {
    const customs = {}
    actions.forEach(item => {
        customs[item['type']] = fn(...item['action'])
    })
    return customs
}

export { STATICPATH, customConfig, customElements2, hasLabelElements, customElements, customShapeAction, customFlowAction }
